Borland Online And The Cobb Group Present:


February, 1994 - Vol. 1 No. 2

Customizing the 3.1 IDE - Creating custom configuration files for your projects

Borland's Integrated Development Environment (IDE) allows you to customize your programming environment in many ways. For example, you can define your own keyboard macros or change the settings of the built-in text editor. However, the custom settings you establish for one situation may not work well in another. The keyboard macros for one project may be inappropriate for another, or you may be sharing a workstation with a programmer who despises your favorite editor settings.

Fortunately, you can customize many of the IDE environment settings on a project-by-project basis. In this article, we'll show you how to set up a configuration file that will store separate IDE settings for a project.

Understanding the TCCONFIG.TC file

Borland C++ uses three files to store the IDE settings: TCCONFIG.TC, project name.PRJ, and project name.DSK. The IDE maintains the PRJ and DSK files and stores them in the project's folder. The PRJ file keeps the current compile and link options for the project, along with the list of files that the project uses. The DSK file contains a list of the files currently open in the IDE, as well as a list of recently used filenames.

The third file, TCCONFIG.TC, contains the current global configuration data for the IDE, including default keyboard shortcuts (macros), editor settings (25- versus 43/50-line mode), mouse settings, and auto-save preferences. By default, the TCCONFIG.TC file is loaded from the \BORLANDC\BIN directory and therefore is common to all projects. However, if you run BC.EXE or BCW.EXE from a directory that contains a second TCCONFIG.TC file, the IDE uses the second configuration file instead.

Creating a project-based configuration file

To create a custom configuration file for a project, we'll first copy the default configuration file from the \BORLANDC\BIN directory to our project file's directory. Then, we'll use a text editor to create a file that contains a definition of a keyboard macro.

After we define our macro, we'll use Borland's macro compiler to merge the macro definition file with our configuration file. We'll also customize the IDE environment to show that the configuration file stores these settings too. Finally, we'll run the IDE to load and test our new macro. Now, let's customize the IDE for one of the example projects that ship with Borland C++.

A custom configuration file for CMDLG.PRJ

To begin, copy the file TCCONFIG.TC from the Borland binary file directory to the directory for the CMDLG.PRJ example project. To do this, enter the following commands from the DOS prompt:

copy \borlandc\bin\tcconfig.tc \borlandc\examples\win31\cmdlg\*.*

Now, run the Borland C++ IDE from DOS by typing \borlandc\bin\bc and pressing the [Return] key. Next, create the text file for your macro by choosing New from the File menu. To create a macro for [Alt]Y that inserts the text of an empty do-while loop, enter

MACRO CppDoWhile
	InsertText("do{}\n");
	InsertText("while()");
	CursorLeft;
END;

Alt-Y : CppDoWhile;

Save your macro to a file by choosing Save As... from the File menu and entering

\borlandc\examples\win31\cmdlg\macro.tem 

in the Save File As text box. Next, shut down the IDE by choosing Quit from the File menu.

Your new macro definition is now in a file, but before you can use it you need to compile the macro file and merge it with TCCONFIG.TC. Compile your macro file and add its definition to the configuration file for this project by entering the following commands at the DOS prompt:

cd \borlandc\examples\win31\cmdlg

temc macro.tem tcconfig.tc

These commands specify the path and name of Borland's macro compiler, the path and name of the macro definition file, and the path and name of the target configuration file. Now, you're ready to test your custom project macro.

Using the project's configuration file

To begin using the new configuration file for the CMDLG.PRJ project, you'll need to run the compiler from the project's directory. Change the directory and start the DOS compiler by entering the following command from the DOS prompt:

bc

When the IDE displays its menubar and desktop area, you can test the new macro. Choose New from the File menu to open a new file window. Next, press [Alt]Y. When the CppDoWhile macro text appears, the window should resemble the one shown in Figure A.


Figure A - The CppDoWhile macro adds the body of a do-while loop to the current source file.

To demonstrate how the Borland C++ IDE saves the editor settings in the configuration file, let's change the number of lines the IDE displays onscreen. Change this setting by choosing Environment from the Options menu, and then choosing Preferences... from the Environment submenu. If you currently use the 25-line mode for viewing the IDE (this is the default), change to the 43/50-line setting. If you currently use the 43/50-line mode, change to the 25-line setting. Select the appropriate setting from the Screen Size radio buttons in the Preferences dialog box, as shown in Figure B.


Figure B - The Preferences dialog box allows you to change the number of character-mode lines the IDE uses for display.

Since the IDE stores the editor preferences in the configuration file, the screen size for this project can be different from that for any other project. In addition, this project will separately maintain any other editor changes in the Preferences or Options|Environment|Editor dialog boxes.

Since you've finished this example, close the new window by choosing Close from the Window menu or by clicking on the window's close icon. When the Message dialog box appears, click on No to close the window and discard the file. To return to DOS, choose Exit from the File menu.

Remember, the CppDoWhile macro is available only when you run the compiler from a directory containing the TCCONFIG.TC file that uses this macro definition. If you want to use this macro on another project, simply copy the configuration file to that project's directory and then run the compiler from that directory.

Conclusion

Different projects (or users) may require distinct types of keyboard macros or different editor settings. Fortunately, you can configure the Borland C++ IDE to use a different set of macros and settings for individual projects that reside in their own directory. In this article, we showed you how to make a custom configuration file for any of your projects and how to save those settings for use with individual Borland C++ projects.

Return to the Borland C++ Developer's Journal index

Subscribe to the Borland C++ Developer's Journal


Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.